Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update refs.mdx #1127

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Update refs.mdx #1127

wants to merge 4 commits into from

Conversation

alexmuzenhardt
Copy link
Contributor

@alexmuzenhardt alexmuzenhardt commented Mar 16, 2025

Signal value should be used as red, not the signal setter.

  • [ x ] I have read the Contribution guide
  • [ x ] This PR references an issue (except for typos, broken links, or other minor problems)

Description(required)

The signals getter should be used as ref, not the signal setter. In the playground it is correct. Just a small mistake in the docs page.

Related issues & labels

  • Suggested label(s) (optional): 'documentation'

Signal value should be used as red, not the signal setter.
Copy link

stackblitz bot commented Mar 16, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Mar 16, 2025

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit b720b8b
🔍 Latest deploy log https://app.netlify.com/sites/solid-docs/deploys/67da930331c57600086cb581
😎 Deploy Preview https://deploy-preview-1127--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines 86 to 92
<button onClick={() => setShow((isShown) => !isShown)}>Toggle</button>

<Show when={show()}>
<p ref={setElement}>This is the ref element</p>
<p ref={element}>This is the ref element</p>
</Show>
</div>
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great pickup! looking at the two, there are multiple things that need to be updated within this code snippet from the playground. Do you mind updating it to reflect that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only thing I would add to the code snippet from the playground ist the code from createEffect. The other things looks fine. If you agree, I can update the PR.

Maybe it would be a good thing to change parameter in the setShow function vom (v) => !v to (isShown) => !isShown. What are your thoughts on that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the createEffect itself is necessary. I mostly mean that the code snippet should look like this:

function App() {
  const [show, setShow] = createSignal(false);
  let element!: HTMLParagraphElement;

  return (
    <div>
      <button onClick={() => setShow((isShown) => !isShown)}>Toggle</button>

      <Show when={show()}>
        <p ref={element}>This is the ref element</p>
      </Show>
    </div>
  );
}

Since we don't need the setElement in this, we can do without the signal itself!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed! I will change that accordingly.

Comment on lines 86 to 92
<button onClick={() => setShow((isShown) => !isShown)}>Toggle</button>

<Show when={show()}>
<p ref={setElement}>This is the ref element</p>
<p ref={element}>This is the ref element</p>
</Show>
</div>
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the createEffect itself is necessary. I mostly mean that the code snippet should look like this:

function App() {
  const [show, setShow] = createSignal(false);
  let element!: HTMLParagraphElement;

  return (
    <div>
      <button onClick={() => setShow((isShown) => !isShown)}>Toggle</button>

      <Show when={show()}>
        <p ref={element}>This is the ref element</p>
      </Show>
    </div>
  );
}

Since we don't need the setElement in this, we can do without the signal itself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants